package demo.configuration;
/**
 * 邢帅教育
 * <p>
 * 本源代码由数据中心及其作者共同所有，未经版权持有者的事先书面授权，
 * 不得使用、复制、修改、合并、发布、分发和/或销售本源代码的副本。
 *
 * @copyright Copyright (c) 2018. xsteach.com all rights reserved.
 */

import demo.component.CupComponent;
import demo.component.DemoComponent;
import demo.component.DemoComponent1;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;

/**
 * @author maikec
 * @date 2018/9/11
 */
@Configuration
//@Profile( "dev" )
@ComponentScan( "demo.component" )
@PropertySource( "application.properties" )
@EnableAspectJAutoProxy
public class DemoConfiguration {

    @Value( "${t}" )
    public String t;
    @Bean(name="demoComponent",initMethod = "init", destroyMethod = "bye")
    @Profile( "dev" )
    public DemoComponent demoComponent() {
        System.out.println( t );
        return new DemoComponent(  );
    }

    @Bean(name="demoComponent1",initMethod = "init")
    @Profile( "dev" )
    public DemoComponent1 demoComponent1(@Value( "${msg}" ) String msg) {
        System.out.println( msg );
        return new DemoComponent1( msg );
    }

    @Bean(name="demoComponent2",initMethod = "init")
    @Profile( "dev" )
    public DemoComponent1 demoComponent2(@Value( "#{demoConfiguration.t}" ) String msg) {
        System.out.println( msg );
        return new DemoComponent1( msg );
    }
}
